<style type="text/css">
    .center{text-align:center;}
</style>
<body>
<div class="bjy-admin-nav">
    <i class="fa fa-home"></i> 首页
    &gt;
    个人信息
<!--     &gt;
    修改头像 -->
</div>
<ul id="myTab" class="nav nav-tabs">
	<li class="active" >
        <a href="{:url('password')}">修改密码</a>
    </li>
<!--     <li >
        <a href="{:url('head_img')}">修改头像</a>
    </li> -->
</ul>
<form class="form-inline">
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
            <th class="center" style="width:100px;line-height:34px;">旧密码：</th>
            <td>
                <input class="form-control" type="password" name="oldpassword" placeholder="请填写旧密码" maxlength="20">
            </td>
        </tr>
        <tr>
            <th class="center" style="width:100px;line-height:34px;">新密码：</th>
            <td>
                <input class="form-control" type="password" name="newpassword" placeholder="请填写新密码" maxlength="20">
            </td>
        </tr>
        <tr>
            <th class="center" style="width:100px;line-height:34px;">重复密码：</th>
            <td>
                <input class="form-control" type="password" name="repassword" placeholder="请填写重复密码" maxlength="20">
            </td>
        </tr>
        <tr>
            <th></th>
            <td>
                <input class="btn btn-success submit" type="button" value="修改">
            </td>
        </tr>
    </table>
</form>
</body>
<script type="text/javascript">
    $('.submit').click(function(){
        var allright = true;
        $('input[name]').each(function(k,v){
            if($.trim($(v).val())==''){
                alert($(v).attr('placeholder'));
                allright = false;
                return false;
            }
        })

        if(!allright) return false;

        if($("[name='newpassword']").val() != $("[name='repassword']").val()){
            alert('两次密码不一致');return ;
        }

        var formdata = $('input[name]').serialize();
        alert(formdata);
        $.post('password',formdata,function(data){
            if(data.code){
                alert(data.msg);
                window.location.href=(data.url);
            }else{
                alert(data.msg);
            }
        },'json');
    });
</script>